Security: Logical ID uniqueness check can be bypassed via substring matching#3911
Open
tuanaiseo wants to merge 1 commit intoaws:developfrom
Open
Conversation
The `verify_unique_logical_id` function uses the `in` operator to compare resource types against `do_not_verify` entries. For mappings where the value is a string (not a list), `in` performs substring checks, not strict equality. This can allow unintended type matches (e.g., crafted type strings that are substrings), potentially bypassing logical ID collision detection and causing transformed resources to overwrite or collide with existing ones. Affected files: verify_logical_id.py Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
reedham-aws
approved these changes
Apr 17, 2026
Contributor
reedham-aws
left a comment
There was a problem hiding this comment.
I disagree that this is a security related fix, but I guess it's a good enough defensive programming adjustment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
verify_unique_logical_idfunction uses theinoperator to compare resource types againstdo_not_verifyentries. For mappings where the value is a string (not a list),inperforms substring checks, not strict equality. This can allow unintended type matches (e.g., crafted type strings that are substrings), potentially bypassing logical ID collision detection and causing transformed resources to overwrite or collide with existing ones.Severity:
mediumFile:
samtranslator/translator/verify_logical_id.pySolution
Use strict type comparison. Normalize
do_not_verifyvalues to lists and compare with equality, e.g.allowed = do_not_verify[resource.resource_type]; allowed_types = allowed if isinstance(allowed, list) else [allowed]; return existing_type in allowed_types.Changes
samtranslator/translator/verify_logical_id.py(modified)Testing